import java.util.List;

class TreeNode{
    TreeNode left;
    String val;
    TreeNode right;

    public TreeNode(String val) {
        this.val = val;
    }
}

public class Main {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        String str = "ABD H  E  CF  G  ";
        TreeNode root = binaryTree.createdTree(str);
        //TreeNode root = binaryTree.createdTree();

        System.out.println("======前序遍历======");
        binaryTree.preOrder(root);
        System.out.println();

        System.out.println("======非递归前序遍历======");
        binaryTree.preOrderNotRecursion(root);
        System.out.println();

        System.out.println("======中序遍历======");
        binaryTree.inOrder(root);
        System.out.println();

        System.out.println("======非递归中序遍历======");
        binaryTree.inOrderNotRecursion(root);
        System.out.println();

        System.out.println("======后序遍历======");
        binaryTree.postOrder(root);
        System.out.println();

        System.out.println("======非递归后序遍历======");
        binaryTree.postOrderNotRecursion(root);
        System.out.println();

        System.out.println("======层序遍历======");
         binaryTree.levelOrder(root);
        System.out.println();

        System.out.println("======获取树中结点的个数======");
        System.out.println(binaryTree.getNodeNum(root));

        System.out.println("======求叶子结点的个数======");
        System.out.println(binaryTree.getLeafNum(root));

        System.out.println("======求只有左结点的结点的个数======");
        System.out.println(binaryTree.getLeftNodeNum(root));

        System.out.println("======求只有右结点的结点的个数======");
        System.out.println(binaryTree.getRightNodeNum(root));

        System.out.println("======求单结点结点的结点的个数======");
        System.out.println(binaryTree.getSingleNodeNum(root));

        System.out.println("======求双结点结点的结点的个数======");
        System.out.println(binaryTree.getBothNodeNum(root));

        System.out.println("======求第k层节点的个数======");
        System.out.println(binaryTree.getKLevelNodeCount(root, 4));

        System.out.println("======求二叉树的高度======");
        System.out.println(binaryTree.getHeight(root));

        System.out.println("======检测二叉树中是否有value元素======");
        TreeNode findVal = binaryTree.find(root, "A");
        if(findVal == null)
            System.out.println("false");
        else
            System.out.println("true"+"\n"+ "value = "+findVal.val);
    }
}